{php include wl_template('common/header');}
<!-- page 容器 -->
<div class="page">
  <!-- 标题栏 -->
  <header class="bar bar-nav">
    <a class="icon icon-me pull-left open-panel"></a>
    <h1 class="title">课代表开启柜门</h1>
  </header>

  <!-- 这里是页面内容区 -->
  <div class="content main" name="main">
    <div class="row no-gutter">
      <div class="col-20" style="text-align:center;">信息ID</div>
      <div class="col-20" style="text-align:center;">设备名称</div>
      <div class="col-10" style="text-align:center;">柜门号</div>
      <div class="col-30" style="text-align:center;">绑定教师</div>
      <div class="col-20" style="text-align:center;"><input type="checkbox" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" />全选</div>
    </div>    
    {loop $current_cabinet $item}
        <div class="row no-gutter">
          <div class="col-20" style="text-align:center;">{$item['info_id']}</div>
          <div class="col-20" style="text-align:center;">{$device_name}</div>
          <div class="col-10" style="text-align:center;">{$item['door']}</div>
          <div class="col-30" style="text-align:center;"><?php if($item['name']=='')  echo '暂无绑定';else echo $item['name'];?></div>          
          <div class="col-20" style="text-align:center;"><input class="check" type="checkbox" info_id="{$item['info_id']}" door="{$item['door']}"/></div>
        </div>        
    {/loop}
    <div class="content-block"><p><a href="#" class="button">课代表开启柜门：{$device_name}</a></p></div>
    <div class="content-block"><p>注意：可以多选，点击按钮后所选柜门将会开启</p></div>
  </div>
  

</div>




<script type="text/javascript">
	$(function(){
        $('.button').click(function(){
            var jsonarray = eval('('+"[]"+')');
            var device_name = "{php echo $device_name}";
            $('.check').each(function(){
                if($(this).prop("checked")==true){
                    jsonarray.push(  
                        {  
                            "info_id" : $(this).attr('info_id'),  
                            "door" : $(this).attr('door'),
                        }  
                    );                     
                }                
            });
            
            //alert(JSON.stringify(jsonarray));
            $.post("{php echo app_url('open/opendoorbutton/select');}", {arr : jsonarray , device_name : device_name},function(data){
                //alert(data);
                 window.location="{php echo app_url('scangenerate/scan/prompt');}&prompt="+data; 
            });             
        });
                   
	});

</script>

{php include wl_template('common/footer');}
	